﻿using EntityModels.Entities;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EntityModels.DbContexts
{
    /// <summary>
    /// 数据种子
    /// </summary>
    public class DataSeedingContext : DbContext
    {
        public DbSet<DataSeedingEntity> DataSeedingEntities => Set<DataSeedingEntity>();

        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            modelBuilder.Entity<DataSeedingEntity>()
                // 使用实体类对象提供数据
                .HasData(new DataSeedingEntity { Id = 1, Text = "Text" });

            modelBuilder.Entity<DataSeedingEntity>()
                // 使用匿名对象提供数据
                .HasData(new { Id = 2, Text = "Text" });

        }

    }
}
